<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/admincontent.jsp" %>

<div id="location">当前位置：内容管理 > 文章管理</div>
<!-- 筛选条件 -->
<div id="sy_search">
    <form id="advanceQueryParam">
        <div style="background-color: #f0f0f0">
            <div class="clearfix more_query_area">
                <div class="query_area_body clearfix">
                    <div class="record_item">
                        <div class="record_item">
                            <div class="label">所属栏目:</div>
                            <div class="content">
                                <div><select name="nodeid">
                                    <option value="-1">不限</option>
                                    ${nodes}
                                </select></div>
                            </div>
                        </div>
                    </div>
                    <div class="record_item">
                        <div class="record_item">
                            <div class="label">招聘方式:</div>
                            <div class="content">
                                <div><select name="cmstype">
                                    <option value="">不限</option>
                                    <option value="高校校园招聘">高校校园招聘</option>
                                    <option value="中专校园招聘">中专校园招聘</option>
                                    <option value="社会招聘">社会招聘</option>
                                    <option value="内部招聘">内部招聘</option>
                                </select></div>
                            </div>
                        </div>
                    </div>
                    <div class="record_item">
                        <div class="record_item">
                            <div class="label">是否下线:</div>
                            <div class="content">
                                <div><select name="isdis" id="isdis">
                                    <option value="-1">全部</option>
                                    <option value="已保存">已保存</option>
                                    <option value="正常">已发布</option>
                                    <option value="已下线">已下线</option>
                                </select></div>
                            </div>
                        </div>
                    </div>
                    <div class="record_item">
                        <div class="record_item">
                            <div class="label">关键字:</div>
                            <div class="content">
                                <div><input type="text" id="title" name="title"/></div>
                                <div><input type="hidden"  name="path" value="${path}"/></div>
                            </div>
                        </div>
                    </div>
                    <div class="record_item">
                        <div class="toolbars">
                            <a id="searchbtn" >
                                <em class="ico16 search_16"></em>
                                <span class="menu_span" title="查询">查询</span>
                            </a>
                            <a id="searchreset">
                                <em class="ico16 refresh_16"></em>
                                <span class="menu_span" title="重置">重置</span>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<div id="Content" class="bg-content">
    <div class="toolbars">
        <a id="cms_add">
            <em id="add_em" class="ico16 add_new"></em>
            <span id="send_span" class="menu_span" title="添加文章">添加文章</span>
        </a>
        <a id="cms_edit">
            <em class="ico16 editor_16"></em>
            <span class="menu_span" title="修改文章">修改文章</span>
        </a>
        <a id="btn_cms_del">
            <em class="ico16 del_16"></em>
            <span class="menu_span" title="删除文章">删除文章</span>
        </a>
        <a id="btn_cms_preview">
            <em class="ico16 preview_16"></em>
            <span class="menu_span" title="预览文章">预览文章</span>
        </a>
        <a id="btn_cms_public">
            <em class="ico16 publish_16"></em>
            <span class="menu_span" title="发布文章">发布文章</span>
        </a>
        <a id="btn_cms_down">
            <em class="ico16 office20_16"></em>
            <span class="menu_span" title="文章下线">文章下线</span>
        </a>
    </div>
<%--    <div id="searchbox">--%>
<%--        <form>--%>
<%--            <table class="treeTable searchform">--%>
<%--                <thead>--%>
<%--                <tr>--%>
<%--                    <td width="80">所属栏目:</td>--%>
<%--                    <td width="120">--%>
<%--                        <div>--%>
<%--                            <select name="nodeid" id="nodeid">--%>
<%--                                <option value="-1">不限</option>--%>
<%--                                ${nodes}</select>--%>
<%--                        </div>--%>
<%--                    </td>--%>
<%--                    <td width="80">招聘方式:</td>--%>
<%--                    <td width="120">--%>
<%--                        <div>--%>
<%--                            <select name="cmstype" id="cmstype">--%>
<%--                                <option value="">不限</option>--%>
<%--                                <option value="高校校园招聘">高校校园招聘</option>--%>
<%--                                <option value="中专校园招聘">中专校园招聘</option>--%>
<%--                                <option value="社会招聘">社会招聘</option>--%>
<%--                                <option value="内部招聘">内部招聘</option>--%>
<%--                            </select>--%>
<%--                        </div>--%>
<%--                    </td>--%>
<%--                    <td width="80">是否下线:</td>--%>
<%--                    <td width="120">--%>
<%--                        <div>--%>
<%--                            <select name="isdis" id="isdis">--%>
<%--                                <option value="-1">全部</option>--%>
<%--                                <option value="已保存">已保存</option>--%>
<%--                                <option value="正常">已发布</option>--%>
<%--                                <option value="已下线">已下线</option>--%>
<%--                            </select>--%>
<%--                        </div>--%>
<%--                    </td>--%>
<%--                    <td width="80">关键字:</td>--%>
<%--                    <td width="200">--%>
<%--                        <div><input type="text" id="title" name="title"/></div>--%>
<%--                    </td>--%>
<%--                    <td>--%>
<%--                        &lt;%&ndash;<button id="searchbtn" type="button" class="layui-btn layui-btn-normal layui-btn-radius">查询</button>&ndash;%&gt;--%>
<%--                        <div class="toolbars">--%>
<%--                            <a id="cms_search">--%>
<%--                                <em class="ico16 search_16"></em>--%>
<%--                                <span class="menu_span" title="查询">查询</span>--%>
<%--                            </a>--%>
<%--                        </div>--%>
<%--                    </td>--%>
<%--                    <td></td>--%>
<%--                </tr>--%>
<%--                </thead>--%>
<%--            </table>--%>
<%--        </form>--%>
<%--    </div>--%>
</div>
<table class="treeTable" id="tablelist" lay-filter="cmsIndexTable"></table>
<script type="text/javascript">
    $(document).ready(function () {
    });

    var tavkeIns;
    let layuithis;
    layui.use('table', function () {
        var table = layui.table;
        layuithis = this;

        tavkeIns = table.render({
            id: 'cmsIndexTable'
            , elem: '#tablelist'
            , url: '/CMS/getlistsLayuiJson'
            , title: '用户数据表'
            , height: 'full'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'id', title: 'ID', fixed: 'left', sort: true}
                , {field: 'nodename', title: '所属栏目', fixed: 'left', sort: true, minwidth: 260}
                , {field: 'cmstype', title: '招聘方式', fixed: 'left', minwidth: 260}
                , {field: 'title', title: '文章标题', minwidth: 400}
                , {field: 'addtime', title: '添加时间', fixed: 'right', sort: true, minwidth: 200}
                , {field: 'adduname', title: '添加人', fixed: 'right', sort: true, minwidth: 120}
                , {field: 'isdis', title: '是否下线', fixed: 'right'}
            ]]
            , page: true
        });
    });

    function getList() {
        var url = '/CMS/getlists';
        $("#page").myPagination({
            cssStyle: "pagination",
            saveChecked: true,
            singleCheck: true,
            ajax: {
                on: true,
                url: url,
                param: $("form").serialize(),
                dataType: 'html',
                callback: function (data) {
                    $("#result").html(data);
                }
            }
        });
    }

    $(function () {

        $("#cms_search").on('click', function () {

                function fun1() {
                    layui.use('table', () => {
                            tavkeIns.reload({
                                url: "/CMS/getlistsLayuiJson",
                                where: {
                                    nodeid: $("#nodeid").val(),
                                    title: $("#title").val(),
                                    cmstype: $("#cmstype").val(),
                                    isdis: $("#isdis").val()
                                },
                                page: {
                                    curr: 1
                                }
                            });
                        }
                    );
                }

                fun1.call(layuithis)
            }
        );


        $("#cms_edit").on('click', function () {
            var url = '/CMS/edit?_x=2015';

            var id = '';
            var checkRows = layui.table.checkStatus('cmsIndexTable').data;
            var count = checkRows.length;

            if (count < 1) {
                layer.msg('请选择一条信息', {icon: 7, time: 2000});
            } else if (count > 1) {
                layer.msg('只能选择一条信息', {icon: 7, time: 2000});
            } else {
                $(checkRows).each(function (index, itme) {
                    id = itme.ids.replace('cb_', '');
                    //id = itme.adduid.replace('cb_', '')+",";
                });
                location = url + '&id=' + id;
            }
        });

        $("#btn_cms_del").on('click', function () {
            layer.confirm('确定要删除该文章吗？', {
                btn: ['是', '否']
            }, function () {

                var checkRows = layui.table.checkStatus('cmsIndexTable').data;
                if (!!!checkRows || checkRows.length == 0) {
                    layer.alert('至少选择一条信息', {icon: 2});
                } else {
                    var ids = "";
                    $(checkRows).each(function (index, itme) {
                        ids = itme.ids.replace('cb_', '') + ",";
                    });
                    $.post("/CMS/DelAction", {id: ids}, function (result) {
                        if (result.state) {
                            layer.alert(result.Message, {icon: 1});
                            //getList();
                            tavkeIns.reload('cmsIndexTable', {
                                page: {
                                    curr: 1
                                }
                            });
                        } else {
                            layer.alert(result.Message, {icon: 2});
                        }
                    }, "JSON");
                }
                layer.closeAll();
            }, function () {
                layer.closeAll();
            });
        });
        $("#btn_cms_preview").on('click', function () {
            layer.confirm('确定要预览该文章吗？', {
                btn: ['是', '否']
            }, function () {
                var checkRows = layui.table.checkStatus('cmsIndexTable').data;

                if (!!!checkRows || checkRows.length == 0) {
                    layer.alert('至少选择一条信息', {icon: 2});
                } else {
                    var ids = "";
                    $(checkRows).each(function (index, itme) {
                        //ids+=itme.replace('cb_', '')+",";
                        ids = itme.ids.replace('cb_', '');
                    });
                    // window.open("/CMS/Preview?id=" + ids);

                    // http://127.0.0.1:8081/ 是系统配置的前端根目录，需要jsp获取  type=1 招聘公告
                    window.open( $('input[name = "path"]').val() +  "/bulletin/detail?id=" + ids + '&type=1');
                }
                layer.closeAll();
            }, function () {
                layer.closeAll();
            });
        });

        $("#btn_cms_public").on('click', function () {
            layer.confirm('确定要发布该文章吗？', {
                btn: ['是', '否']
            }, function () {
                var checkRows = layui.table.checkStatus('cmsIndexTable').data;

                if (!!!checkRows || checkRows.length == 0) {
                    layer.alert('至少选择一条信息', {icon: 2});
                } else {
                    var ids = "";
                    $(checkRows).each(function (index, itme) {
                        ids = itme.ids.replace('cb_', '') + ",";
                    });
                    $.post("/CMS/PublishCMS", {id: ids}, function (result) {
                        if (result.state) {
                            layer.alert(result.Message, {icon: 1});
                            //getList();
                            tavkeIns.reload('cmsIndexTable', {
                                page: {
                                    curr: 1
                                }
                            });
                        } else {
                            layer.alert(result.Message, {icon: 2});
                        }
                    }, "JSON");

                }
                layer.closeAll();
            }, function () {
                layer.closeAll();
            });
        });
        $("#btn_cms_down").on('click', function () {
            layer.confirm('确定要下线该文章吗？', {
                btn: ['是', '否']
            }, function () {
                var checkRows = layui.table.checkStatus('cmsIndexTable').data;
                if (!!!checkRows || checkRows.length == 0) {
                    layer.alert('至少选择一条信息', {icon: 2});
                } else {
                    var ids = "";
                    $(checkRows).each(function (index, itme) {
                        ids = itme.ids.replace('cb_', '') + ",";
                    });
                    $.post("/CMS/DownCMS", {id: ids}, function (result) {
                        if (result.state) {
                            layer.alert(result.Message, {icon: 1});
                            //getList();
                            tavkeIns.reload('cmsIndexTable', {
                                page: {
                                    curr: 1
                                }
                            });
                        } else {
                            layer.alert(result.Message, {icon: 2});
                        }
                    }, "JSON");

                }
                layer.closeAll();
            }, function () {
                layer.closeAll();
            });
        })
    });
</script>
</body>
<link rel="stylesheet" href="<%=basepath%>/resources/css/skin.css"/>
</html>